const http = require('http')
// 创建服务
const server  = http.createServer((request,response)=>{
    // console.log('method:',request.method);
    // console.log('headers:',request.headers);
    // console.log('url',request.url);
    const {pathname,searchParams} = new URL(request.url,'http://localhost:8989')
    console.log('pathname',pathname);
    console.log('searchParams:',searchParams);
    const username = searchParams.get('username')
    const pwd = searchParams.get('pwd')
    console.log('username:',username);
    console.log('pwd:',pwd);

    // body参数
    request.on('data',(buffer)=>{
        console.log('请求实体数据',buffer.toString());
    })

    response.end(`<a href="https://baidu.com">'Hello http!'</a>`)
})

// 启动服务
server.listen(8989,()=>{
    console.log('启动服务: http://localhost:8989');
    (function(){console.log('测试');})()

})